package com.hg.common.vo;

import com.hg.common.enums.ResultEnum;
import lombok.Data;

import java.io.Serializable;

/**
 * http请求返回的对象
 * Created by skh on 2017/12/13
 */
@Data
public class ResultVO implements Serializable {
	private Integer code;
	private String msg;
	private Object data;

	public static ResultVO success(Object object) {
		ResultVO resultVO = new ResultVO();
		resultVO.setCode(ResultEnum.SUCCESS.getCode());
		resultVO.setMsg(ResultEnum.SUCCESS.getMessage());
		resultVO.setData(object);
		return resultVO;
	}

	public static ResultVO success(){
		return success(null);
	}

	public static ResultVO fail(Integer code, String msg) {
		ResultVO resultVO = new ResultVO();
		resultVO.setCode(code);
		resultVO.setMsg(msg);
		return resultVO;
	}
}